package com.example.visitmanage.viewmodel

import androidx.lifecycle.MutableLiveData
import com.example.lib_base.entity.AnnouncementBean
import com.example.lib_base.entity.VisisterBean
import com.example.lib_base.entity.VisisterBeanItem
import com.example.lib_base.mvvm.BaseViewModel
import com.example.visitmanage.repo.VisitManagerRepo
import dagger.hilt.android.lifecycle.HiltViewModel
import okhttp3.RequestBody
import javax.inject.Inject

@HiltViewModel
class VisitManagerViewModel @Inject constructor(private val repo:VisitManagerRepo):BaseViewModel() {

    val visisterSuccess= MutableLiveData<VisisterBean>()
    val visisterSucces= MutableLiveData<VisisterBean>()
    val addvisisterSuccess= MutableLiveData<VisisterBeanItem>()
   // val noticeError = MutableLiveData<String>()
   val errorMsg = MutableLiveData<String>()

    fun getVisister(){
        //httpRequest({repo.apiService.getAnnouncements(page, size)},{noticeSuccess.postValue(it)})
        httpRequest({repo.apiService.getVisister()},{visisterSuccess.postValue(it)})
    }
    fun getVisisterByStatus(status:String){

        httpRequest({repo.apiService.getVisisterByStatus(status)},{visisterSuccess.postValue(it)})
    }
    fun addVisister(body: Any){
        httpRequest(
            {repo.addVisister(repo.mapTopBody(body))},
            {addvisisterSuccess.postValue(it)},
            {errorMsg.postValue(it)}
        )
    }


}